<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String contextPath = request.getContextPath();
%>
<html>
<head>
	<title></title>
	<jsp:include page="../../inc.jsp"></jsp:include>
</head>
<body>
	    <div class="easyui-panel" title="增加汽车票" style="width:300px">
        	<div style="padding:10px 60px 20px 60px">
        
			    <form id="ticketForm" method="post">
				    <div>
				    	<div> 
				    		<div>出发城市:</div>
				            <input id="startCity" class="easyui-combobox" name="startCityId" editable="false"
				        		data-options="valueField:'id',textField:'cityName',url:'city!getCitiesWeb.action',
				        		onSelect: function(rec){
		            				var url = 'passengerStation!getPassengerStation.action?cityId='+rec.id;
		            				$('#startPassengerStation').combobox('reload', url);
		        				}">
				        </div>
				        
				        <div>
			            	<div>出发客运站:</div>
				            <input id="startPassengerStation" class="easyui-combobox" name="startPassengerId" editable="false"
				        		data-options="valueField:'id',textField:'passengerStationName'">
				        </div>
				        
				        <div>
			            	<div>出发时间：</div>
				        	<input id="startTime" class="easyui-datetimebox" name="startTime" editable="false"
				            	data-options="required:true,showSeconds:false" style="width:150px">
			            </div>
			            
			            <div>
			            	<div>车次：</div>
				            <input id="busNumber" class="easyui-textbox" name="busNumber" style="width:150px">
				        </div>
				        
				        <div>
			            	<div>到达城市：</div>
				            <input id="endCity" class="easyui-combobox" name="endCityId" editable="false"
				        		data-options="valueField:'id',textField:'cityName',url:'city!getCitiesWeb.action',
				        		onSelect: function(rec){
		            				var url = 'site!getSite.action?cityId='+rec.id;
		            				$('#endSite').combobox('reload', url);
		        				}">
				        </div>
				        
				        <div>
			            	<div>到达地点：</div>
				        	<input id="endSite" class="easyui-combobox" name="endSiteId" editable="false"
				        		data-options="valueField:'id',textField:'siteName'">
			        	</div>
			        	
			        	<div>
			        		<div>客车类型：</div>
				        	<input id="busType" class="easyui-textbox" name="busType" style="width:150px">
				        </div>
				        
				        <div>
			            	<div>价格：</div>
				        	<input id="price" class="easyui-textbox" name="price" style="width:150px">
				        </div>
				        
				        <div>
			            	<div>车票数：</div>
				        	<input id="inventory" class="easyui-textbox" name="inventory" style="width:150px">
			        	</div>
				    </div>
		        </form>
        	<div style="text-align:center;padding:5px">
          <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Submit</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">Clear</a>
       	</div>
       </div>
    </div>
        <script>
        function submitForm(){
        	 $('#ticketForm').form('submit',{
             	url:'ticket!addTicket.action',
             	onSubmit:function(){
             		return $(this).form('validate');
             	},
             	success:function(){
             		var result = eval('('+result+')');
                    if (result.errorMsg){
                        $.messager.show({
                            title: 'Error',
                            msg: result.errorMsg
                        });
                    } else {
                    	
                    }
             	}
             });
        }
       
        function clearForm(){
            $('#ticketForm').form('clear');
        }
    </script>
</body>